<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="js,css,html,">










<meta name="description" content="新知识  以下是我边找工作边学习的前端知识，希望在这段时间学习的过程中，能够解答自己一直学习开发小程序所遇到的问题，然后变成自己的东西。">
<meta name="keywords" content="js,css,html">
<meta property="og:type" content="article">
<meta property="og:title" content="前端知识">
<meta property="og:url" content="http://Anzusen.com/2021/03/14/前端学习/index.html">
<meta property="og:site_name" content="Anzhusen">
<meta property="og:description" content="新知识  以下是我边找工作边学习的前端知识，希望在这段时间学习的过程中，能够解答自己一直学习开发小程序所遇到的问题，然后变成自己的东西。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://anzusen.com/image/原型链.png">
<meta property="og:updated_time" content="2021-03-14T06:34:56.042Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="前端知识">
<meta name="twitter:description" content="新知识  以下是我边找工作边学习的前端知识，希望在这段时间学习的过程中，能够解答自己一直学习开发小程序所遇到的问题，然后变成自己的东西。">
<meta name="twitter:image" content="http://anzusen.com/image/原型链.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://Anzusen.com/2021/03/14/前端学习/">





  <title>前端知识 | Anzhusen</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
    <a href="https://github.com/ananzhusen/ananzhusen.github.io" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewbox="0 0 250 250" style="fill:#64CEAA; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Anzhusen</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://Anzusen.com/2021/03/14/前端学习/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="ananzhusen">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/touxiang.JPG">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Anzhusen">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">前端知识</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2021-03-14T13:59:55+08:00">
                2021-03-14
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/前端/" itemprop="url" rel="index">
                    <span itemprop="name">前端</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2021/03/14/前端学习/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2021/03/14/前端学习/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv">本文总阅读量 <i class="fa fa-file-o"></i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>次
            </span>
          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  2.7k
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  10
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="新知识"><a href="#新知识" class="headerlink" title="新知识"></a>新知识</h3><p>  以下是我边找工作边学习的前端知识，希望在这段时间学习的过程中，能够解答自己一直学习开发小程序所遇到的问题，然后变成自己的东西。<br><a id="more"></a></p>
<h4 id="CSS"><a href="#CSS" class="headerlink" title="CSS"></a>CSS</h4><ol>
<li>行内元素和块级元素</li>
</ol>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 行内元素转化为块级元素 --&gt;</span></span><br><span class="line"></span><br><span class="line">  元素&#123;</span><br><span class="line">   display:block;</span><br><span class="line">   &#125;</span><br><span class="line"><span class="comment">&lt;!-- 块级元素转化为行内元素 --&gt;</span></span><br><span class="line">元素&#123;</span><br><span class="line">	display:inline-block;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ol start="2">
<li>智能表单</li>
</ol>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">form</span> <span class="attr">action</span>=<span class="string">"test.php"</span> <span class="attr">method</span>=<span class="string">"get"</span> <span class="attr">autocomplete</span>=<span class="string">"off"</span> <span class="attr">novalidate</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"email"</span> <span class="attr">name</span>=<span class="string">""</span> <span class="attr">autocomplete</span>=<span class="string">"on"</span>&gt;</span><span class="comment">&lt;!-- 邮箱 --&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"range"</span> <span class="attr">name</span>=<span class="string">""</span>&gt;</span> <span class="comment">&lt;!-- 滑块 --&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"color"</span> <span class="attr">name</span>=<span class="string">""</span>&gt;</span>  <span class="comment">&lt;!-- 颜色 --&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 等等 --&gt;</span></span><br></pre></td></tr></table></figure>
<ul>
<li>form</li>
</ul>
<table>
<thead>
<tr>
<th style="text-align:left">属性</th>
<th style="text-align:center">值</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">autocomplete</td>
<td style="text-align:center">on    /off</td>
<td style="text-align:left">规定是否启用表单的自动完成功能。</td>
</tr>
<tr>
<td style="text-align:left">novalidate</td>
<td style="text-align:center">novalidate</td>
<td style="text-align:left">如果使用该属性，则提交表单时不进行验证。</td>
</tr>
</tbody>
</table>
<ul>
<li>input</li>
</ul>
<table>
<thead>
<tr>
<th style="text-align:left">属性</th>
<th style="text-align:center">值</th>
<th style="text-align:left">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">autofocus</td>
<td style="text-align:center">autofocus</td>
<td style="text-align:left">规定输入字段在页面加载时是否获得焦点。（不适用于 type=”hidden”）</td>
</tr>
<tr>
<td style="text-align:left">form</td>
<td style="text-align:center">另一个form的id属性值</td>
<td style="text-align:left">规定输入字段所属的一个或多个表单。</td>
</tr>
</tbody>
</table>
<ol start="3">
<li>获取页面元素及其操作</li>
</ol>
<blockquote>
<p>document.querySelector(“选择器”)；</p>
</blockquote>
<ul>
<li>可以是css中的任意一种选择器,通过该选择器只能选中第一个元素。</li>
</ul>
<blockquote>
<p>document.querySelectorAll(“选择器”);</p>
<ul>
<li>与document.querySelector区别： querySelectorAll 可以选中所有符合选择器规则的元素，返回的是一个列表。querySelector返回的只是单独的一个元素</li>
</ul>
</blockquote>
<blockquote>
<p>Dom.classList.add(“类名”): 给当前dom元素添加类样式<br>Dom.classList.remove(“类名”); 给当前dom元素移除类样式<br>classList.contains(“类名”); 检测是否包含类样式<br>classList.toggle(“active”);  切换类样式（有就删除，没有就添加）</p>
</blockquote>
<ol start="4">
<li>自定义属性 </li>
</ol>
<blockquote>
<p>data-自定义属性名<br>在标签中，以data-自定义名称  </p>
</blockquote>
<ul>
<li>获取自定义属性 </li>
</ul>
<blockquote>
<p>Dom.dataset   返回的是一个对象<br> Dom.dataset.属性名  /  Dom.dataset[属性名]<br>        属性名是不包含data-,data-name-age -&gt; NameAge (驼峰命名法)</p>
</blockquote>
<ul>
<li>设置自定义属性</li>
</ul>
<blockquote>
<p>Dom.dataset.自定义属性名=值  或者  Dom.dataset[自定义属性名]=值；</p>
</blockquote>
<ol start="5">
<li>读取文件</li>
</ol>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">"file"</span> <span class="attr">name</span>=<span class="string">""</span>&gt;</span></span><br><span class="line"></span><br><span class="line">	<span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">"text/javascript"</span>&gt;</span><span class="undefined"></span></span><br><span class="line"><span class="undefined">		</span></span><br><span class="line"><span class="undefined">		var input=document.querySelector("input");</span></span><br><span class="line"><span class="undefined"></span></span><br><span class="line"><span class="undefined">		input.onchange=function()&#123;</span></span><br><span class="line"><span class="undefined"></span></span><br><span class="line"><span class="undefined">			//获取到文件</span></span><br><span class="line"><span class="undefined">			var file=this.files[0];</span></span><br><span class="line"><span class="undefined"></span></span><br><span class="line"><span class="undefined">			//开始读取，创建读取器</span></span><br><span class="line"><span class="undefined">			var  reader=new FileReader();</span></span><br><span class="line"><span class="undefined"></span></span><br><span class="line"><span class="undefined">			//开始读取</span></span><br><span class="line"><span class="undefined">			reader.readAsText(file);//图片使用 reader.readAsDataURL(file);</span></span><br><span class="line"><span class="undefined"></span></span><br><span class="line"><span class="undefined">			//获取读取的结果</span></span><br><span class="line"><span class="undefined">			//当文件读取完成后，才可以获取文件信息内容</span></span><br><span class="line"><span class="undefined">			reader.onload=function() &#123;</span></span><br><span class="line"><span class="undefined">				console.log(reader.result);</span></span><br><span class="line"><span class="undefined">			&#125;			</span></span><br><span class="line"><span class="undefined">		&#125;</span></span><br><span class="line"><span class="undefined"></span></span><br><span class="line"><span class="undefined">	</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br></pre></td></tr></table></figure>
<ol start="6">
<li>背景图片设置</li>
</ol>
<ul>
<li><p>background-origin：   规定背景图片的定位区域。<br>  padding-box    背景图像相对内边距定位（默认值）<br>  border-box     背景图像相对边框定位【以边框左上角为参照进行位置设置】<br>  content-box    背景图像相对内容区域定位【以内容区域左上角为参照进行位置设置】</p>
<p> 备注： 默认盒子的背景图片是在盒子的内边距左上角对齐设置。</p>
</li>
</ul>
<ul>
<li><p>background-clip：       规定背景的绘制区域。</p>
<p>  border-box     背景被裁切到边框盒子位置 【将背景图片在整个容器中显示】<br>  padding-box     背景被裁切到内边距区域【将背景图片在内边距区域（包含内容区域）显示】<br>  content-box     背景被裁切到内容区域【将背景图片在内容区域显示】</p>
</li>
</ul>
<ul>
<li><p>background-size：     规定背景图片的尺寸。</p>
<p>  cover    将背景图片按照原来的比例铺满容器，不能保证完整呈现<br>  contain   将背景图片按照原来的比例缩放，完整的放入容器，不确定是否将容器填充满</p>
</li>
</ul>
<ol start="7">
<li><p>边框</p>
<ul>
<li>box-shadow：      盒子阴影</li>
<li>border-radius：   边框圆角</li>
<li>border-image:      边框图片</li>
</ul>
</li>
</ol>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"> <span class="comment">/* 设置边框图片 */</span></span><br><span class="line"> <span class="selector-tag">border-image-source</span>: <span class="selector-tag">url</span>("");</span><br><span class="line"></span><br><span class="line"> <span class="comment">/* 边框图片裁切（九宫格方式切割） : 不需要带单位*/</span></span><br><span class="line"> <span class="selector-tag">border-image-slice</span>: 20 20 20 20;</span><br><span class="line"></span><br><span class="line"> <span class="comment">/* 设置边框图片的平铺方式 */</span></span><br><span class="line"> <span class="comment">/* border-image-repeat: stretch;   (变形拉伸)*/</span></span><br><span class="line"> <span class="selector-tag">border-image-repeat</span>: <span class="selector-tag">round</span>; <span class="comment">/*(推荐使用)*/</span></span><br><span class="line"><span class="comment">/*  border-image-repeat: repeat; */</span> </span><br><span class="line"></span><br><span class="line"><span class="selector-tag">border-image-width</span>: 20<span class="selector-tag">px</span>;</span><br></pre></td></tr></table></figure>
<ol start="8">
<li>选择器</li>
</ol>
<ul>
<li><p>属性选择器： </p>
<p>  [属性名=值] {}<br>  [属性名] {}       匹配对应的属性即可<br>  [属性名^=值] {}    以值开头<br>  [属性名*=值] {}    包含<br>  [属性名$=值] {}       以值结束</p>
</li>
<li><p>结构伪类选择器：</p>
<pre><code>:first-child {}     选中  父元素  中第一个子元素
:last-child {}      选中父元素中最后一个子元素
:nth-child(n) {}    选中父元素中正数第n个子元素
:nth-last-child(n) {}    选中父元素中倒数第n个子元素
</code></pre><p>备注；<br>   n 的取值大于等于0<br>   n 可以设置预定义的值</p>
<pre><code>odd[选中奇数位置的元素]  
even【选中偶数位置的元素】
</code></pre><p>   n 可以是一个表达式：</p>
<pre><code>an+b的格式
</code></pre></li>
<li><p>其他选择器：<br> :target          被锚链接指向的时候会触发该选择器<br> ::selection         当被鼠标选中的时候的样式<br> ::first-line     选中第一行<br> ::first-letter     选中第一个字符</p>
<p><a href="https://blog.csdn.net/qq_27674439/article/details/90608220" target="_blank" rel="noopener">伪元素和伪类的区别总结</a></p>
</li>
</ul>
<ol start="9">
<li>flex布局</li>
</ol>
<ul>
<li><p>设置父元素为伸缩盒子【直接父元素】</p>
<pre><code>display： flex
</code></pre><p>为什么在伸缩盒子中，子元素会在一行上显示？</p>
<pre><code>1. 子元素是按照伸缩盒子中主轴方向显示
2. 只有伸缩盒子才有主轴和侧轴
3. 主轴： 默认水平从左向右显示
4。 侧轴： 始终要垂直于主轴
</code></pre></li>
<li><p>设置伸缩盒子主轴方向（flex-direction）</p>
</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">  	<span class="selector-tag">flex-direction</span>: <span class="selector-tag">row</span>; 【默认值】</span><br><span class="line"><span class="selector-tag">flex-direction</span>: <span class="selector-tag">row-reverse</span>;</span><br><span class="line"><span class="selector-tag">flex-direction</span>: <span class="selector-tag">column</span>;</span><br><span class="line"><span class="selector-tag">flex-direction</span>: <span class="selector-tag">column-reverse</span>;</span><br></pre></td></tr></table></figure>
<ul>
<li>设置元素在主轴的对齐方式( justify-content)</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 设置子元素在主轴方向的对齐方式 */</span></span><br><span class="line">	<span class="selector-tag">justify-content</span>: <span class="selector-tag">flex-start</span>;</span><br><span class="line">	<span class="selector-tag">justify-content</span>: <span class="selector-tag">flex-end</span>;</span><br><span class="line">	<span class="selector-tag">justify-content</span>: <span class="selector-tag">center</span>;</span><br><span class="line">	<span class="selector-tag">justify-content</span>: <span class="selector-tag">space-between</span>;  <span class="comment">/*两个子元素之间有空白 两边对齐 中间子元素间留有空白*/</span></span><br><span class="line">	<span class="selector-tag">justify-content</span>: <span class="selector-tag">space-around</span>;  <span class="comment">/*空白环绕 两个子元素之间有空白 两边子元素靠边的一边有一半空白 */</span></span><br></pre></td></tr></table></figure>
<ul>
<li><p>设置元素在侧轴的对齐方式 （align-items）</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">align-items</span>: <span class="selector-tag">flex-start</span>;</span><br><span class="line"><span class="selector-tag">align-items</span>: <span class="selector-tag">flex-end</span>;</span><br><span class="line"><span class="selector-tag">align-items</span>: <span class="selector-tag">center</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">/* 默认值 */</span></span><br><span class="line"><span class="selector-tag">align-items</span>: <span class="selector-tag">stretch</span>;</span><br></pre></td></tr></table></figure>
</li>
<li><p>设置元素是否换行显示（flex-wrap）</p>
<ol>
<li>在伸缩盒子中所有的元素默认都会在一行上显示</li>
<li>如果希望换行：<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">flex-wrap: wrap | nowrap;</span><br></pre></td></tr></table></figure>
</li>
</ol>
</li>
<li><p>设置元素换行后的对齐方式（ align-content）</p>
</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">   <span class="selector-tag">align-content</span>: <span class="selector-tag">flex-start</span>;</span><br><span class="line"><span class="selector-tag">align-content</span>: <span class="selector-tag">flex-end</span>;</span><br><span class="line"><span class="selector-tag">align-content</span>: <span class="selector-tag">center</span>;</span><br><span class="line"><span class="selector-tag">align-content</span>: <span class="selector-tag">space-around</span>;</span><br><span class="line"><span class="selector-tag">align-content</span>: <span class="selector-tag">space-between</span>;</span><br><span class="line"><span class="comment">/* 换行后的默认值 */</span></span><br><span class="line"><span class="selector-tag">align-content</span>: <span class="selector-tag">stretch</span>;</span><br></pre></td></tr></table></figure>
<ul>
<li>设置子元素缩放比</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*子元素中设置*/</span></span><br><span class="line">	   <span class="selector-tag">flex</span><span class="selector-pseudo">:1</span>;</span><br></pre></td></tr></table></figure>
<ol start="10">
<li>清除浮动</li>
</ol>
<p>本质：清除浮动元素脱离标准流造成的影响<br>原因：父级元素没有高度 子盒子浮动 影响下面布局</p>
<ul>
<li>额外标签法（不常用）</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"> <span class="comment">&lt;!-- 在最后一个 子 盒子后面再添加一个盒子，并且必须是块级元素不能是行内元素--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>  <span class="attr">style</span>=<span class="string">"clear: both;"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br></pre></td></tr></table></figure>
<ul>
<li>父级添加 overflow</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">.father&#123;</span><br><span class="line">	overflow: hidden;</span><br><span class="line">	<span class="comment">&lt;!-- 或者设置为auto、scroll --&gt;</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li><p>父级添加 :after伪元素<br>（相当于在父级内部后面添加盒子）</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">.clearfix:after&#123;</span><br><span class="line">				content: "";</span><br><span class="line">				display: block;</span><br><span class="line">				height: 0;</span><br><span class="line">				clear: both;</span><br><span class="line">				visibility: hidden;</span><br><span class="line">			&#125;</span><br><span class="line">.clearfix&#123;</span><br><span class="line">	/*IE6、7专有*/</span><br><span class="line">	*zoom: 1;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>清除浮动 双伪元素清除浮动</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">.clearfix:before,.clearfix:after&#123;</span><br><span class="line">				content: "";</span><br><span class="line">				display: table;</span><br><span class="line">			&#125;</span><br><span class="line">			.clearfix:after&#123;</span><br><span class="line">				clear: both;</span><br><span class="line">			&#125;</span><br><span class="line">			.clearfix&#123;</span><br><span class="line">				*zoom: 1;</span><br><span class="line">			&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<ol start="11">
<li>css做等边三角形</li>
</ol>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">div&#123;</span><br><span class="line">	border-top: 30px solid transparent;</span><br><span class="line">	border-left: calc(30*1.732px) solid green;</span><br><span class="line">	border-bottom: 30px solid transparent;</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>
<ol start="12">
<li>BFC（块级格式化上下文）<br>原理：形成一个完全独立的空间，让空间里的子元素不会影响外面的布局。</li>
</ol>
<ul>
<li>margin塌陷<br> 上下子元素之间margin不取和而是取最大值<br> 解决办法：为其中一个子元素外面包裹父元素，并且设置父元素{overflow:hidden},形成新的”平行空间” </li>
<li><p>浮动元素令父元素高度塌陷问题</p>
<p> 详见：10.清除浮动</p>
</li>
<li><p>自适应布局（文字环绕等问题）</p>
<p>解决：在环绕元素添加属性：{overfloat:hidden}</p>
</li>
</ul>
<h4 id="JS"><a href="#JS" class="headerlink" title="JS"></a>JS</h4><ol>
<li>返回值</li>
</ol>
<p><code>var p1=new Person();</code></p>
<ul>
<li>a、如果函数没有返回值(没有return语句)，那么就会返回构造函数的实例</li>
<li>b、如果函数返回了一个基本数据类型(数字、字符串、布尔值、null、undefined)的值，那么本次构造函数的返回值是该实例</li>
<li>c、如果函数返回了一个复杂数据类型的值，那么本次函数的返回值就是该值</li>
</ul>
<ol start="2">
<li>call</li>
</ol>
<ul>
<li>改变this的指向</li>
</ul>
<p>例子：<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">   <span class="comment">//使用call实现继承</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">Father</span>(<span class="params">name,age</span>)</span>&#123;</span><br><span class="line">			<span class="keyword">this</span>.name = name;</span><br><span class="line">			<span class="keyword">this</span>.age = age;</span><br><span class="line">		&#125;</span><br><span class="line">		</span><br><span class="line">		<span class="function"><span class="keyword">function</span> <span class="title">Son</span>(<span class="params">name,age,score</span>)</span>&#123;</span><br><span class="line">			Father.call(<span class="keyword">this</span>,name,age)</span><br><span class="line">			<span class="keyword">this</span>.score = score</span><br><span class="line">		&#125;</span><br><span class="line">		</span><br><span class="line">		<span class="keyword">var</span> s1 =<span class="keyword">new</span> Son(<span class="string">"小明"</span>,<span class="number">18</span>,<span class="number">100</span>);</span><br><span class="line">		<span class="built_in">console</span>.log(s1)</span><br><span class="line">		</span><br><span class="line"><span class="comment">//Son &#123;name: "小明", age: 18, score: 100,__proto__: Object&#125;</span></span><br></pre></td></tr></table></figure></p>
<ol start="3">
<li>原型对象</li>
</ol>
<ul>
<li>原型链（图来自pink老师学习教程）</li>
</ul>
<p><img src="/image/原型链.png" alt="原型链"></p>
<ol start="4">
<li>类和对象</li>
</ol>
<p>constructor里面的this指向实例对象，方法里面的this指向这个方法的调用者。</p>
<ol start="5">
<li>闭包</li>
</ol>
<p>闭包：closure指有权访问另一个函数作用域中的变量的函数</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">&lt;script type=<span class="string">"text/javascript"</span>&gt;</span><br><span class="line">		</span><br><span class="line">		<span class="comment">// 闭包的主要作用:延伸了变量的作用范围</span></span><br><span class="line">		<span class="function"><span class="keyword">function</span> <span class="title">fn</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">			<span class="keyword">var</span> num = <span class="number">10</span>;</span><br><span class="line">			<span class="function"><span class="keyword">function</span> <span class="title">fun</span>(<span class="params"></span>)</span>&#123; </span><br><span class="line">				<span class="built_in">console</span>.log(num)</span><br><span class="line">			&#125;</span><br><span class="line">			fun();</span><br><span class="line">		&#125;</span><br><span class="line">		fn();</span><br><span class="line">		</span><br><span class="line">		</span><br><span class="line">		<span class="function"><span class="keyword">function</span> <span class="title">fn1</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">			<span class="keyword">var</span> num = <span class="number">110</span>;</span><br><span class="line">			<span class="comment">// function fun1()&#123;</span></span><br><span class="line">			<span class="comment">// 	console.log(num)</span></span><br><span class="line">			<span class="comment">// &#125;</span></span><br><span class="line">			<span class="comment">//  return fun1;</span></span><br><span class="line">			</span><br><span class="line">			<span class="keyword">return</span> <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123; <span class="comment">//匿名函数</span></span><br><span class="line">				<span class="built_in">console</span>.log(num)</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">var</span> f =  fn1(); <span class="comment">//全局访问函数内部局部变量</span></span><br><span class="line">		f(); </span><br><span class="line">	&lt;<span class="regexp">/script&gt;</span></span><br></pre></td></tr></table></figure>
<ol start="6">
<li><p>浅拷贝和深拷贝</p>
<p>浅拷贝只拷贝最外一层，更深的层拷贝的是存储值的地址，也就是指向被拷贝对象的对应的地址，语法糖：Object.assign(拷贝对象,被拷贝对象);</p>
</li>
<li><p>const</p>
<p>const不能改变复杂数据类型的整个值，但可以改变里面的每一项，其实就是不能改变这个值的内存地址。</p>
</li>
</ol>
<ol start="8">
<li>Set数据结构</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//set数据结构   类似数组，但成员是唯一的  eg:搜索历史</span></span><br><span class="line">		</span><br><span class="line">		<span class="keyword">let</span> arry = [<span class="number">1</span>,<span class="number">3</span>,<span class="number">3</span>,<span class="number">35</span>,<span class="number">3</span>,<span class="number">6</span>,<span class="number">7</span>] </span><br><span class="line">		<span class="keyword">const</span>  s1 = <span class="keyword">new</span> <span class="built_in">Set</span>(arry);<span class="comment">// 数组去重</span></span><br><span class="line">		<span class="built_in">console</span>.log(s1.size)</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//添加/删除Set数据结构中的一个成员</span></span><br><span class="line">	    <span class="built_in">console</span>.log(s1.add(<span class="string">'s'</span>).add(<span class="string">'a'</span>).add(<span class="string">'s'</span>)); <span class="comment">//只添加一个's'</span></span><br><span class="line">		s1.delete(<span class="number">1</span>)  <span class="comment">//返回true/false</span></span><br><span class="line">		<span class="built_in">console</span>.log(s1);</span><br><span class="line">		</span><br><span class="line">		</span><br><span class="line">		<span class="comment">// 判断是否为Set数据结构的成员</span></span><br><span class="line">		<span class="built_in">console</span>.log(s1.has(<span class="string">'s'</span>));</span><br><span class="line">		</span><br><span class="line">		</span><br><span class="line">		s1.forEach(<span class="function"><span class="params">value</span>=&gt;</span>&#123;</span><br><span class="line">			<span class="built_in">console</span>.log(value);</span><br><span class="line">		&#125;)</span><br><span class="line">		</span><br><span class="line">		<span class="comment">//清空</span></span><br><span class="line">		s1.clear();</span><br><span class="line">		<span class="built_in">console</span>.log(s1);</span><br></pre></td></tr></table></figure>
<ol start="9">
<li>数据类型</li>
</ol>
<ul>
<li>返回为true/false总结</li>
</ul>
<p>|数据类型    |转换为true的值    |转换为false的值|<br>|Boolean    |true    |false        |<br>|String     |任何非空字符串    |空字符串    |<br>|Number    |任何非零数字值（包括无穷大）    |0和Null    |<br>|Object    |任何对象    |nSull        |<br>|Undefined    |            |Undefined    |</p>
<h3 id="兼容性问题解决"><a href="#兼容性问题解决" class="headerlink" title="兼容性问题解决"></a>兼容性问题解决</h3><ol>
<li><p>语义标签</p>
<p>ie低版本无法识别h5新的语义标签</p>
</li>
</ol>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">   <span class="comment">&lt;!--[if lte IE 8]&gt; </span></span><br><span class="line"><span class="comment">	&lt;script type="text/javascript" src="js插件/html5shiv.min.js"&gt;&lt;/script&gt;</span></span><br><span class="line"><span class="comment">&lt;![endif]--&gt;</span></span><br></pre></td></tr></table></figure>
<ol start="2">
<li>多媒体标签</li>
</ol>
<p><a href="https://www.w3school.com.cn/html5/html_5_video.asp" target="_blank" rel="noopener">video 元素支持三种视频格式及浏览器支持</a><br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">  <span class="tag">&lt;<span class="name">video</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">source</span> <span class="attr">src</span>=<span class="string">"code/多媒体标签/trailer.mp4"</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">source</span> <span class="attr">src</span>=<span class="string">"trailer.ogg"</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">source</span> <span class="attr">src</span>=<span class="string">"trailer.WebM"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">video</span>&gt;</span></span><br></pre></td></tr></table></figure></p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>你可以对我进行打赏哦</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/weichat.jpg" alt="ananzhusen 微信支付">
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.jpg" alt="ananzhusen 支付宝">
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/js/" rel="tag"># js</a>
          
            <a href="/tags/css/" rel="tag"># css</a>
          
            <a href="/tags/html/" rel="tag"># html</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2020/08/08/前端知识（实习）/" rel="next" title="前端知识">
                <i class="fa fa-chevron-left"></i> 前端知识
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
<span class="jiathis_txt">分享到：</span>
<a class="jiathis_button_fav">收藏夹</a>
<a class="jiathis_button_copy">复制网址</a>
<a class="jiathis_button_email">邮件</a>
<a class="jiathis_button_weixin">微信</a>
<a class="jiathis_button_qzone">QQ空间</a>
<a class="jiathis_button_tqq">腾讯微博</a>
<a class="jiathis_button_douban">豆瓣</a>
<a class="jiathis_button_share">一键分享</a>

<a href="http://www.jiathis.com/share?uid=2140465" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank">更多</a>
<a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript">
var jiathis_config={
  data_track_clickback:true,
  summary:"",
  shortUrl:false,
  hideMore:false
}
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js?uid=" charset="utf-8"></script>
<!-- JiaThis Button END -->
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/touxiang.JPG" alt="ananzhusen">
            
              <p class="site-author-name" itemprop="name">ananzhusen</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">23</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">13</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">43</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/ananzhusen" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://weibo.com/5817162963" target="_blank" title="weibo">
                      
                        <i class="fa fa-fw fa-weibo"></i>weibo</a>
                  </span>
                
            </div>
          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                Links
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="https://gitee.com/anzhusen/" title="gitee" target="_blank">gitee</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#新知识"><span class="nav-number">1.</span> <span class="nav-text">新知识</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#CSS"><span class="nav-number">1.1.</span> <span class="nav-text">CSS</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#JS"><span class="nav-number">1.2.</span> <span class="nav-text">JS</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#兼容性问题解决"><span class="nav-number">2.</span> <span class="nav-text">兼容性问题解决</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">ananzhusen</span>

  
</div>

<!-- 
  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>
 -->



        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      本站访客数 <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      本站访问总量 <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: 'e69lyQSoCtoaLGljT3kXLBEQ-gzGzoHsz',
        appKey: 'pRDcFfyQnO4jQWxElUFupJ2D',
        placeholder: 'Just go go',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  

  

  

  


  
   <canvas class="fireworks" style="position: fixed;left: 0;top: 0;z-index: 1; pointer-events: none;"></canvas> 
   <script type="text/javascript" src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script> 
   <script type="text/javascript" src="/js/src/fireworks.js"></script>
  

</body>
</html>
